<fieldset>
    <legend>Add Discount</legend>
    <form method="post" action="{{$base_index_url}}/{{$current_module}}/admin/{{$current_controller}}/add_discount" onsubmit="$.blockUI();">
        Description<input type="text" name="discount_desc" />
        Amount <input type="text" name="discount_amount" size="2" />
        <select name="discount_type"><option value="$">$</option>
            <option value="%">%</option>
        </select>
        <input type="submit" value="Add Discount"/>
        <input type="hidden" name="order_id" value="{{$order->id}}"/>
    </form>
</fieldset>
{{if $order->DYN_discounts<>""}}
<fieldset>
    <legend>Current Discounts</legend>
    
    <table id="table">
        <tr>
            <th>Description</th>
            <th style="text-align: right">Amount</th>
            <th style="text-align: center">Action</th>
        </tr>
        {{foreach from=$order->DYN_discounts item=discount}}
        <tr class="table_row">
            <td style="width: 20%">
                {{$discount->discount_desc}}
            </td>
            <td style="text-align: right;">
                {{if $discount->type=="$"}}
                <span style="color:#AEA8A8;font-weight: bold">$</span>{{ $discount->amount}}
                {{else}}
                    {{$discount->amount}}<span style="color:#AEA8A8;font-weight: bold">%</span>
                {{/if}}
            </td>
            <td style="text-align: center">
                <form name="d_{{$discount->id}}" id="d_{{$discount->id}}" method="post" action="{{$base_index_url}}/{{$current_module}}/admin/{{$current_controller}}/delete_discount" >                    
                    <input type="hidden" name="discount_id" value="{{$discount->id}}" />
                    <input type="hidden" name="order_id" value="{{$order->id}}" />
                </form>
                <button onclick="delete_discount('d_{{$discount->id}}');" >Delete</button>
            </td>
        </tr>
        {{/foreach}}
    </table>
</fieldset>
<script type="text/javascript">
    function delete_discount(fid){
        if(confirm('You sure you want to delete this discount ?')){
            $.blockUI();
            document.forms[fid].submit()
        }
    }
</script>
{{else}}
{{/if}}